// 0 模块化编程
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// 1.定于路由组件
import Home from '@/views/Home.vue';

// 2.定义选项对象 routes
const routes = [{
    path: '/',
    redirect: '/home'
},
{
    path: '/home',
    name: 'home',
    component: Home
},
{
    path: '/find',
    name: 'find',
    component: () => import('@/views/Find.vue') // 路由懒加载
},
{
    path: '/mine',
    name: 'mine',
    component: () => import('@/views/Mine.vue') // 路由懒加载
},
{
    path: '/vuex',
    name: 'vuex',
    component: () => import('@/views/Vuex.vue') // 路由懒加载
},
{
    path: '/404',
    name: 'notfound',
    component: () => import('@/views/404.vue')
},
{
    path: '*',
    redirect: {
        name: 'notfound'
    }
}
]

// 3.创建路由对象
const router = new VueRouter({
    routes,
    mode: 'hash'
})


// 4.挂载到根实例
export default router
